/**
 * 登录相关API
 */
import request from '@/utils/request';
export const serviceHead = '/auth'; // 项目前缀

/**
* 获取验证码
* @param params
* @returns {*}
*/
export function getCodeImg () {
  return request({
    url: `/code`,
    method: 'get'
  });
};

/**
 * 账号登录
 * @param params
 * @returns {*}
 */
export function login (params) {
  return request({
    url: `${serviceHead}/login`,
    method: 'post',
    loading: true,
    data: params
  });
};

/**
* 注册账号
* @param params
* @returns {*}
*/
export function register (params) {
  return request({
    url: `${serviceHead}/register`,
    method: 'post',
    loading: true,
    data: params
  });
};

/**
* 刷新 token
* @param params
* @returns {*}
*/
export function refreshToken () {
  return request({
    url: `${serviceHead}/refresh`,
    method: 'post'
  });
};

/**
 * 退出账户
 * @returns {*}
 */
export function logout () {
  return request({
    url: `${serviceHead}/logout`,
    method: 'delete'
  });
};